$(document).ready(function() {

	var setting = {
		check: {
			enable: true
		},
		data: {
			simpleData: {
				enable: true
			}
		},
		view: {
			addDiyDom: function(treeId, treeNode) {
				if(!treeNode.children) {
					var objNode = $("#" + treeNode.tId);
					objNode.append("<a class='car car-icons'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>")
				}
			}
		},
		callback: {
			onCheck: function(e, treeId, treeNode) {
				console.log(treeNode.id);
			},
			onClick: function(e, treeId, treeNode) {
				console.log(treeNode.id);
			}
		}
	};

	var zNodes = [{
		id: 1,
		pId: 0,
		name: "车辆",
		open: true
	}, {
		id: 11,
		pId: 1,
		name: "粤A66666"
	}, {
		id: 12,
		pId: 1,
		name: "粤A40626"
	}, {
		id: 13,
		pId: 1,
		name: "粤A66269"
	}, {
		id: 14,
		pId: 1,
		name: "粤A27766"
	}, {
		id: 15,
		pId: 1,
		name: "粤A60966"
	}, {
		id: 16,
		pId: 1,
		name: "粤A00006"
	}, {
		id: 2,
		pId: 0,
		name: "终端",
		open: true
	}, {
		id: 21,
		pId: 2,
		name: "终端001"
	}, {
		id: 22,
		pId: 2,
		name: "终端002"
	}, {
		id: 23,
		pId: 2,
		name: "终端003"
	}, {
		id: 24,
		pId: 2,
		name: "终端004"
	}, {
		id: 25,
		pId: 2,
		name: "终端005"
	}, {
		id: 26,
		pId: 2,
		name: "终端006"
	}, ];

	var newCount = 1;

	$.fn.zTree.init($("#resourceList"), setting, zNodes);

	//	启动-停止车辆  
	$("#resourceList").on("click", ".car-icons", function() {
		var carObj = $(this);
		if(!carObj.siblings(".chk").hasClass("checkbox_true_full")) {
			alert("请勾选车辆!");
			return;
		}
		if(carObj.hasClass("car-stop")) {
			carObj.removeClass("car-stop");
		} else {
			$(this).addClass("car-stop");
		}
	});

	// 动态标绘的滚动条
	$('#resourceList').mCustomScrollbar({
		scrollInertia: 200,
		mouseWheel: {
			scrollAmount: 400
		}
	});

});